<!-- NewPracticeCompanyDetail_frame.html -->
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
		<title>企业详情</title>
		<link rel="stylesheet" href="../../css/api.css" />
		<link rel="stylesheet" href="../../css/mui.min.css"/>
		<link rel="stylesheet" href="../../css/base.css"/>
		<link rel="stylesheet" href="../../css/CFNetPP_Base.css">
		<link rel="stylesheet" href="../../css/newPractice.css">
		<style type="text/css">
			html,body{
				margin: 0;
				padding: 0;
			}
			p{
				margin: 0;
				padding: 0;
			}
			.img-div{
				width: calc(100% - 2px);
				padding-bottom: calc(100% - 2px);
				background-image: url(../../image/icon_compentition_introduce.jpg);
				background-repeat: no-repeat;
			    background-size: cover;
			    background-position: center;
			}
			.company-info-div{
				padding: 10px;
				overflow: hidden;
			}
			.info-left-div{
				width: 100px;
				height: 100px;
				padding: 10px;
				float: left;
			}
			.company-img{
				width: 80px;
				height: 80px;
			}
			.info-right-div{
				width: calc(100% - 100px);
				float: right;
			}
			.right-content-div{
				border-left: 3px solid #d65357;
				min-height: 100px;
				padding: 10px;
				padding-left: 20px;
			}
			.right-content-div .title-p{
				line-height: 1em;
				margin-bottom: 10px;
			}
			.right-content-div .sub-title{
				line-height: 1.4em;
			}
			.company-detail-box{
				padding: 10px 20px;
				background-color: white;
			}
			.company-detail-div{
				overflow: hidden;
			 	text-overflow: ellipsis;
			 	display: -webkit-box;
			}
			.company-detail-hide-div{
				-webkit-line-clamp: 8;
			 	-webkit-box-orient: vertical;
			}
			.company-detail-more{
				padding: 10px;
				text-align: center;
				background-color: white;
			}
			.company-more-img{
				width: 14px;
				position: relative;
				top: 2px;
				left: 0;
			}
			.practice-tab-div {
			     padding: 0; 
			}
			.practice-tab .practice-tab-subview{
				height: 28px;
			}
			.practice-tab-subview .tab-btn{
				padding: 0 6px;
				height: 28px;
			}
			.btn-span{
				text-overflow: ellipsis;
				width: 100%;
				overflow: hidden;
				line-height: 28px;
			}
		</style>
	</head>
	<body>
		<div class="top-div">
			<div class="mui-table-view company-info-div">
				<div class="company-info-content-div">
					<div class="info-left-div">
						<img id="company_logo" class="company-img" src="../../image/course_placehoder.png">
					</div>
					<div class="info-right-div">
						<div class="right-content-div">
							<p id="company_name" class="base_dark_grey_shallow base_title_font title-p">
								公司名称
							</p>
							<p class="base_dark_grey_shallow base_tag_font sub-title">
								规模 : <span id="company_guimo">--</span>
							</p>
							<p class="base_dark_grey_shallow base_tag_font sub-title">
								行业 : <span id="company_hangye">--</span>
							</p>
							<p class="base_dark_grey_shallow base_tag_font sub-title">
								性质 : <span id="company_xingzhi">--</span>
							</p>
						</div>
					</div>
				</div>
			</div>
			<div class="train-div mui-table-view">
				<div class="company-detail-box">
					<div id="company_detail" class="company-detail-div base_grey base_tag_font">
						公司简介
					</div>
				</div>
				<div hidden="hidden" id="show_more_btn" class="company-detail-more base_dark_grey_shallow base_content_font" onclick="showMoreClick()">
					点击展开<img id="show_more_img" class="company-more-img" src="../../image/icon_down_triangle.png">
				</div>
			</div>
			<div class="hot-news-title">
				<span class="base_dark_grey_shallow base_content_font hot-news-title-span">
					轮岗岗位
				</span>
			</div>
			<div class="train-div mui-table-view">
				<div id="post_tableview" class="practice-tab-div">
					<!-- <div class="practice-tab-box">
						<div class="practice-tab">
							<div class="practice-tab-subview practice-tab-title">
								<span class="btn-span">
									<button type="button" class="mui-btn mui-btn-block tab-btn">仓储规划岗</button>
								</span>
							</div>
						</div>
					</div> -->
				</div>
			</div>
		</div>
	</body>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/jquery.min.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script type="text/javascript" src="../../script/timeStampTool.js"></script>
	<script type="text/javascript">
		var postArr = new Array();
		var currentPost = null;
		apiready = function() {
			loadCompanyData();
			setupNotifi();
		}
		function setupNotifi(){
			api.addEventListener({
			    name: 'practiceApplySucceedNotifi'
			}, function(ret, err) {
			    if (currentPost != null) {
			    	var postData = ret.value;
			    	var postid = postData.postid;
			    	if (postid == currentPost.postid) {
			    		currentPost.apply_status = 1;
			    	}
			    }
			});
		}
		function loadCompanyData(){
			var params = {
				companyid : api.pageParam.id,
				uid : $api.getStorage('cfnetppuid')
			};
			api.showProgress({
			    style: 'default',
			    animationType: 'fade',
			    title: '数据加载中...',
			    text: '',
			    modal: false
			});
			cfnetppPOST(url_newPracticeCompanyDetail, params, true, function(data, status){
				api.hideProgress();
				if (status == 'success') {
					if (data.code == 200) {
						var companyData = data.data.company_list;
						setupDetail(companyData);
					}
				}
			});
		}
		function escape2Html(str) {
		 	var arrEntities={'lt':'<','gt':'>','nbsp':' ','amp':'&','quot':'"'};
		 	return str.replace(/&(lt|gt|nbsp|amp|quot);/ig,function(all,t){return arrEntities[t];});
		}
		function setupDetail(companyData){
			$('#company_name').text(nullString(companyData.company_name));
			$('#company_guimo').text(nullString(companyData.company_dimensions));
			$('#company_hangye').text(nullString(companyData.company_industry));
			$('#company_xingzhi').text(nullString(companyData.company_nature));
			var company_detail = companyData.company_detail;
			if (company_detail == null || company_detail == '') {
				company_detail = '暂无简介';
			}
			// company_detail = escape2Html(company_detail);
			$('#company_detail').html(company_detail);
			var company_logo = companyData.company_logo;
			if (company_logo == null || company_logo == '') {
				company_logo = '../../image/course_placehoder.png';
			}else if(company_logo.indexOf("http") == -1){
				company_logo = '../../image/course_placehoder.png';
			}
			$('#company_logo').attr('src', company_logo);
			var rowNum = Math.round($("#company_detail").height()/parseFloat($("#company_detail").css('line-height')));
			if (rowNum > 8) {
				$('.company-detail-div').addClass('company-detail-hide-div');
				$('#show_more_btn').show();
			}
			var post_list = companyData.post_list;
			if (post_list != undefined && post_list != null && post_list.constructor == Array && post_list.length > 0) {
				postArr = post_list;
				var htmlString = '';
				for (var i = 0; i < post_list.length; i++) {
					var postData = post_list[i];
					htmlString += postCellHtml(i, postData);
				}
				$('#post_tableview').html(htmlString);
				setupPostCellClick();
			}
		}
		function setupPostCellClick(){
			$('.practice-tab-box').unbind('click');
			$('.practice-tab-box').click(function(){
				var index = $(this).attr('index');
				var postData = postArr[parseInt(index)];
				postData["id"] = postData.postid;
				if (postData.apply_status == 1) {
					api.toast({
					    msg: '已申请该岗位，请耐心等待工作人员联系'
					});
					return;
				}
				currentPost = postData;
				api.openWin({useWKWebView:true,
				    name: 'NewPracticeApply_win',
				    url: 'NewPracticeApply_win.html',
				    pageParam: postData
				});
			});
		}
		function postCellHtml(index, data){
			return '<div index="'+index+'" class="practice-tab-box">'+
						'<div class="practice-tab">'+
							'<div class="practice-tab-subview practice-tab-title">'+
								'<button type="button" class="mui-btn mui-btn-block tab-btn">'+
										'<span class="btn-span">'+
											data.post_name+
										'</span>'+
									'</button>'+
							'</div>'+
						'</div>'+
					'</div>';
		}
		function showMoreClick(){
			if ($('.company-detail-div').hasClass('company-detail-hide-div')) {
				$('.company-detail-div').removeClass('company-detail-hide-div');
				$('#show_more_img').attr('src', '../../image/icon_up_triangle.png');
			}else{
				$('.company-detail-div').addClass('company-detail-hide-div');
				$('#show_more_img').attr('src', '../../image/icon_down_triangle.png');
			}
		}
		function nullString(str){
			if (str == null || str == '') {
				return '--';
			}
			return str;
		}
	</script>
</html>